﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.IO;
using MobileOSMLib;

namespace MobileOSMLibTest
{
    public partial class FormMain : Form
    {
        OSMTilesProvider provider = new OSMTilesProvider();
        public FormMain()
        {
            InitializeComponent();
            comboBoxMaps.SelectedIndex = 0;
        }

        private void buttonTest_Click(object sender, EventArgs e)
        {
            try
            {
                pictureBoxMap.Image = provider.requestTile(18303, 10786, 15);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        private void GoogleMap()
        {
            Coordinate coordinate = new Coordinate(52.2500, 21.0833);
            GoogleUrlBuilder builder = new GoogleUrlBuilder();
            builder.CenterCoordinate = coordinate;
            builder.MapType = "mobile";
            builder.ZoomLevel = 12;

            MobileMap map = new MobileMap(builder.MapUrl);
            pictureBoxMap.Image = map.Map;
        }

        private void OsmMap()
        {
            
            OsmUrlBuilder builder = new OsmUrlBuilder();
            builder.ZoomLevel = 12;
            Coordinate coordinate = new Coordinate(52.2500, 21.0833, builder.ZoomLevel);
            builder.CenterCoordinate = coordinate;

            MobileMap map = new MobileMap(builder.MapUrl);
            pictureBoxMap.Image = map.Map;
        }

        private void VirtualEarth()
        {
            VirtualEarthUrlBuilder builder = new VirtualEarthUrlBuilder();
            builder.ZoomLevel = 12;
            Coordinate coordinate = new Coordinate(52.2500, 21.0833, builder.ZoomLevel);
            builder.CenterCoordinate = coordinate;

            MobileMap map = new MobileMap(builder.MapUrl);
            pictureBoxMap.Image = map.Map; 
        }

        private void comboBoxMaps_SelectedIndexChanged(object sender, EventArgs e)
        {
            int i = comboBoxMaps.SelectedIndex;
            switch (i)
            {
                case 0:
                    break;
                case 1:
                    GoogleMap();
                    break;
                case 2:
                    OsmMap();
                    break;
                case 3:
                    VirtualEarth();
                    break;
                default:
                    return;

            }
        }




    }
}